home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / falcon / programm.ing / falclib2.lzh / ROUTS / ICE.S < prev    next >
Text File  |  1994-05-16  |  3KB  |  162 lines

  1. *
  2. * ICE.S
  3. *
  4. *    @icedecrunch
  5. *
  6. *    Checks if the data is icepacked and possibly unpacks it.
  7. *
  8. * In    a0.l=Data adr.
  9. *
  10.  
  11.  
  12. ;********************************************* Unpacking routine of PACK-ICE
  13. ; a0 = AdTRESs of packed data
  14. ; "bsr" or "jsr" to ice_decrunch_2 with register a0 prepared.
  15. @icedecrunch
  16.     link    a3,#-120
  17.     movem.L    d0-a6,-(sp)
  18.     lea    120(a0),a4
  19.     move.L    a4,a6
  20.     bsr    .getinfo
  21.     cmpi.L    #'ICE!',d0
  22.     bne.S    .not_packed
  23.     bsr.s    .getinfo
  24.     lea.L    -8(a0,d0.L),a5
  25.     bsr.s    .getinfo
  26.     move.L    d0,(sp)
  27.     adda.L    d0,a6
  28.     move.L    a6,a1
  29.     moveq    #119,d0
  30. .save    move.B    -(a1),-(a3)
  31.     dbf    d0,.save
  32.     move.L    a6,a3
  33.     move.B    -(a5),d7
  34.     bsr.s    .normal_bytes
  35.     move.L    a3,a5
  36.     bsr    .get_1_bit
  37.     bcc.s    .no_picture
  38.     move.W    #$0f9f,d7
  39.     bsr    .get_1_bit
  40.     bcc.s    .ice_00
  41.     moveq    #15,d0
  42.     bsr    .get_d0_bits
  43.     move.W    d1,d7
  44. .ice_00    moveq    #3,d6
  45. .ice_01    move.W    -(a3),d4
  46.     moveq    #3,d5
  47. .ice_02    add.W    d4,d4
  48.     addx.W    d0,d0
  49.     add.W    d4,d4
  50.     addx.W    d1,d1
  51.     add.W    d4,d4
  52.     addx.W    d2,d2
  53.     add.W    d4,d4
  54.     addx.W    d3,d3
  55.     dbra    d5,.ice_02
  56.     dbra    d6,.ice_01
  57.     movem.W    d0-d3,(a3)
  58.     dbra    d7,.ice_00
  59. .no_picture
  60.     movem.L    (sp),d0-a3
  61.  
  62. .move    move.B    (a4)+,(a0)+
  63.     subq.L    #1,d0
  64.     bne.s    .move
  65.     moveq    #119,d0
  66. .TRESt    move.B    -(a3),-(a5)
  67.     dbf    d0,.TRESt
  68. .not_packed    movem.L    (sp)+,d0-a6
  69.     unlk    a3
  70.     rts
  71. .getinfo    moveq    #3,d1
  72. .getbytes    lsl.L    #8,d0
  73.     move.B    (a0)+,d0
  74.     dbf    d1,.getbytes
  75.     rts
  76. .normal_bytes    
  77.     bsr.s    .get_1_bit
  78.     bcc.s    .test_if_end
  79.     moveq.L    #0,d1
  80.     bsr.s    .get_1_bit
  81.     bcc.s    .copy_direkt
  82.     lea.L    .direkt_tab+20(pc),a1
  83.     moveq.L    #4,d3
  84. .nextgb    move.L    -(a1),d0
  85.     bsr.s    .get_d0_bits
  86.     swap.W    d0
  87.     cmp.W    d0,d1
  88.     dbne    d3,.nextgb
  89. .no_more add.L    20(a1),d1
  90. .copy_direkt    move.B    -(a5),-(a6)
  91.     dbf    d1,.copy_direkt
  92. .test_if_end    cmpa.L    a4,a6
  93.     bgt.s    .strings
  94.     rts    
  95. .get_1_bit    add.B    d7,d7
  96.     bne.s    .Bitfound
  97.     move.B    -(a5),d7
  98.     addx.B    d7,d7
  99. .Bitfound    rts    
  100. .get_d0_bits    
  101.     moveq.L    #0,d1
  102. .hole_bit_loop    
  103.     add.B    d7,d7
  104.     bne.s    .on_d0
  105.     move.B    -(a5),d7
  106.     addx.B    d7,d7
  107. .on_d0    addx.W    d1,d1
  108.     dbf    d0,.hole_bit_loop
  109.     rts    
  110. .strings    lea.L    .Length_tab(pc),a1
  111.     moveq.L    #3,d2
  112. .get_length_bit    
  113.     bsr.s    .get_1_bit
  114.     dbcc    d2,.get_length_bit
  115. .no_length_bit    
  116.     moveq.L    #0,d4
  117.     moveq.L    #0,d1
  118.     move.B    1(a1,d2.W),d0
  119.     ext.W    d0
  120.     bmi.s    .no_über
  121. .get_über    bsr.s    .get_d0_bits
  122. .no_über    move.B    6(a1,d2.W),d4
  123.     add.W    d1,d4
  124.     beq.s    .get_offset_2
  125.     lea.L    .more_offset(pc),a1
  126.     moveq.L    #1,d2
  127. .getoffs    bsr.s    .get_1_bit
  128.     dbcc    d2,.getoffs
  129.     moveq.L    #0,d1
  130.     move.B    1(a1,d2.W),d0
  131.     ext.W    d0
  132.     bsr.s    .get_d0_bits
  133.     add.W    d2,d2
  134.     add.W    6(a1,d2.W),d1
  135.     bpl.s    .depack_bytes
  136.     sub.W    d4,d1
  137.     bra.s    .depack_bytes
  138. .get_offset_2    
  139.     moveq.L    #0,d1
  140.     moveq.L    #5,d0
  141.     moveq.L    #-1,d2
  142.     bsr.s    .get_1_bit
  143.     bcc.s    .Less_40
  144.     moveq.L    #8,d0
  145.     moveq.L    #$3f,d2
  146. .Less_40 bsr.s    .get_d0_bits
  147.     add.W    d2,d1
  148. .depack_bytes
  149.     lea.L    2(a6,d4.W),a1
  150.     adda.W    d1,a1
  151.     move.B    -(a1),-(a6)
  152. .dep_b    move.B    -(a1),-(a6)
  153.     dbf    d4,.dep_b
  154.     bra    .normal_bytes
  155. .direkt_tab    dc.L    $7fff000e,$00ff0007,$00070002,$00030001,$00030001
  156.     dc.L     270-1,    15-1,     8-1,     5-1,     2-1
  157. .Length_tab    dc.B    9,1,0,-1,-1
  158.     dc.B    8,4,2,1,0
  159. .more_offset    dc.B      11,   4,   7,  0    ; Bits lesen
  160.     dc.W    $11f,  -1, $1f    ; Standard Offset
  161. ende_ice_decrunch_2
  162.